package gui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JRadioButton;

import model.Location;
import model.Mob;

import dao.Field;

import service.Service;

class PanelButtom extends JPanel {
	
	private int gridHeight;
	private int gridWidth;
	private Dimension size;
	private JRadioButton jrbSniper, jrbRocket;
	private JButton jbBuy,jbCancel,jbMovement;
	
	
	public PanelButtom(int depth, int width){
		this.gridHeight = depth;
		this.gridWidth = width;
		setBackground(Color.GRAY);
		this.size = new Dimension(0,0);
		
		
		jrbSniper = new JRadioButton("Sniper Tower");
//		jbSniper.setMnemonic(KeyEvent.VK_S);
		jrbSniper.addActionListener(new JRBSniperActionListener());
		jrbSniper.setBackground(Color.BLUE);
		this.add(jrbSniper);
		jrbSniper.setEnabled(true);
		
		
		jrbRocket = new JRadioButton("Rocket Tower");
//		jbRocket.setMnemonic(KeyEvent.VK_R);
		jrbRocket.addActionListener(new JRBRocketActionListener());
		jrbRocket.setBackground(Color.BLUE);
		this.add(jrbRocket);
		jrbRocket.setEnabled(true);
		
		ButtonGroup bg = new ButtonGroup();
		bg.add(jrbSniper);
		bg.add(jrbRocket);
		
		jbBuy = new JButton("Buy");
		jbBuy.setBackground(Color.GREEN);
		jbBuy.setSize(width, depth);
		this.add(jbBuy);
		jbBuy.setVisible(true);
		
		jbCancel = new JButton("Cancel");
		jbCancel.setBackground(Color.GREEN);
		jbCancel.setSize(width, depth);
		this.add(jbCancel);
		jbCancel.setVisible(true);
		
		jbMovement = new JButton("Move");
		jbMovement.setBackground(Color.GREEN);
		jbMovement.setSize(width, depth);
		this.add(jbMovement);
		jbMovement.addActionListener(new JButtonActionListener());
		jbMovement.setVisible(true);
		
		
		
				
	}

	
	public Dimension getPreferredSize(){
		return new Dimension(gridWidth*10, gridHeight*10);
	}
	
	
	private class JButtonActionListener implements ActionListener{

		@Override
		public void actionPerformed(ActionEvent arg0) {
			// TODO Auto-generated method stub
			if(arg0.getSource()== jbMovement){
				System.out.println("actionPerformed");
				Service s = Service.getService();
				s.movementOnField();
				
				
				
			}
			
		}
		
	}

	
	private class JRBSniperActionListener implements ActionListener {

		@Override
		public void actionPerformed(ActionEvent arg0) {
			// TODO Auto-generated method stub
			
		}
		
	}
	
	private class JRBRocketActionListener implements ActionListener{

		@Override
		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			
		}
		
	}
	
}
